<template>
	<view class="k_wrap">
		<view class="k_left"> 
			<view class="f_one" :style="{background:acIndex==index?'green':''}"  @click="toLoadChild(item._id,index)" v-for="(item,index) in parList">{{item.dep_ment}}</view>
		</view>
		<view class="k_right">
			<view style="color:blue; margin: 20px 0 0 20px;" v-for="item in childList">{{item.dep_name}}</view>
		</view>
	</view>
</template>

<script setup>
	import {ref} from 'vue'
	import {getParentKe,getChildKe} from '@/api/home.js'
	
	let parList=ref([])
	let getParentList=async ()=>{
		let res=await getParentKe()
		console.log(res,"-------------------")
		parList.value=res.data;
		toLoadChild(res.data[0]._id)//默认 父科室的 第一个id去加载 子科室
	}
	getParentList();
	
	let acIndex=ref(0);

	// 获取子科室 的列表
	let childList=ref([])
	let toLoadChild=async (_id,index)=>{
		acIndex.value=index//激活下标
		let res=await getChildKe(_id)
		console.log(res,"子科室")
		childList.value=res.data[0].dep_ment_list; //存储子科室列表
		
	}
</script>

<style lang="scss">
	.k_wrap{
		width: 100vw;
		height: 100vh;
		overflow-y: auto;
		display: flex;
		
	}
	.k_left{
		width: 200rpx;
		background: pink;
		.f_one{
			margin-top: 10px;
			height: 60rpx;
			line-height:60rpx;
			text-align: center;
		}
	}
	.k_right{
		flex:1;
	}
</style>